export const TokenKey = 'FIRE_CMS_TOKEN'
export const infoKey = 'FIRE_CMS_USERINFO'
export const MenuCollapseStatusKey = "FIRE_CMS_MENU_COLLAPSE_STATUS"
export const HistoryKey = "FIRE_CMS_HISTORY"

//base
export function getItem(key) {
  const val = localStorage.getItem(key)
  return JSON.parse(val)
}

export function setItem(key, val) {
  return localStorage.setItem(key, JSON.stringify(val))
}

export function removeItem(key) {
  return localStorage.removeItem(key)
}

export function clearAll() {
  return localStorage.clear()
}

//end base
export function getToken() {
  return getItem(TokenKey)
}

export function setToken(token) {
  return setItem(TokenKey, token)
}

export function getUserInfo() {
  return getItem(infoKey) || {}
}

export function setUserInfo(info) {
  return setItem(infoKey, info)
}

export function removeToken() {
  return removeItem(TokenKey)
}

export function setMenuCollapseStatus(val) {
  return setItem(MenuCollapseStatusKey, val)
}

export function getMenuCollapseStatus() {
  return getItem(MenuCollapseStatusKey) || false
}

export function setHistory(val) {
  return setItem(HistoryKey, val)
}

export function getHistory() {
  return getItem(HistoryKey)
}
